import Vue from "vue";
import VueRouter from "vue-router";
import Main from '@views/Main.vue';
import Mall from '@views/Mall/index.vue';
import User from '@views/User/index.vue';
import Home from '@views/home/index.vue';
import Page1 from '@views/others/page1/index.vue';
import Page2 from '@views/others/page2/index.vue';
import Login from '@views/login/login.vue';
import register from '@views/register/register.vue';
import notFound from '@views/response/404.vue';
Vue.use(VueRouter);
// 1.创建路由组件
// 2.将组件和路由进行映射
// 3.创建router实例
const routes = [
    // 主路由
    {path:'/login',component:Login},
    {path:'/register',component:register},
    {path:'/404',component:notFound},
    {
        path:'/',
        component:Main,
        children:[
            //子路由
            {path:'/',component:Home},
            {path:'user',component:User},
            {path:'mall',component:Mall},
            {path:'page1',component:Page1},
            {path:'page2',component:Page2},
        ]
       
    }
]

const router = new VueRouter({
    routes,
})
router.beforeEach((to,from,next)=>{
    console.log(to)
    next()
  })
export default router;